package com.lab303.powerproject.config;

import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class LoginInterceptor implements HandlerInterceptor {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)throws Exception{
        Object manager = request.getSession().getAttribute("loginManager");
        if(manager == null){
            request.setAttribute("msg","没有操作权限，请先登录。");
            response.sendRedirect("/power");
            return false;
        }else {
            return true;
        }
    }
}
